import { ProColumns } from "@ant-design/pro-components";
import { Button } from "antd";

export interface propsType {
  id?: string | undefined;
  open: boolean;
  close: (isEdit?: boolean) => void;
}

export interface reducibleTimeType {
  startTime: string;
  endTime: string;
  key: number;
}

export interface orderTimeType {
  week: string;
  orderTime: reducibleTimeType[];
}

export interface CourseType {
  id: string;
  name: string;
  desc?: string;
  group?: string; //适龄人群
  baseAbility?: string;
  limitNumber: number;
  duration: number; //课程持续时长
  reserveInfo?: string;
  refundInfo?: string;
  otherInfo?: string;
  reducibleTime?: orderTimeType[];
}

export const columnsConfig: ProColumns<CourseType>[] = ({
  editClick,
  orderTimeClick,
  cardClick,
}: {
  editClick: () => void;
  orderTimeClick: () => void;
  cardClick: () => void;
}) => [
  {
    dataIndex: "index",
    valueType: "indexBorder",
    width: 48,
  },
  {
    title: "课程标题",
    dataIndex: "name",
    copyable: true,
    formItemProps: {
      rules: [
        {
          required: true,
          message: "请输入查询值",
        },
      ],
    },
  },
  {
    title: "限制人数",
    dataIndex: "limitNumber",
    search: false,
    align: "center",
    width: 75,
  },
  {
    title: "持续时长",
    dataIndex: "duration",
    align: "center",
    search: false,
    width: 75,
  },
  {
    title: "操作",
    valueType: "option",
    width: 300,
    align: "center",
    render(_text: any, item: { id: any }) {
      return (
        <>
          <Button type="link" onClick={() => editClick(item.id)}>
            编辑
          </Button>
          <Button type="link" onClick={() => orderTimeClick(item.id)}>
            可约时间
          </Button>
          <Button type="link" onClick={() => cardClick(item.id)}>
            消费卡
          </Button>
        </>
      );
    },
  },
];
